package com.gitee.minimalismstyle.fresh.common.core.validate

import com.gitee.minimalismstyle.fresh.common.core.exception.MessageException

class OptionValueValidate : ValueValidate {

    override fun check(value: Any?, params: String?): ValidateResult {
        return if(value == null || value.equals("")){
            ValidateResult(true)
        } else if(params == null || params.equals("")){
            throw MessageException(message = "请设置选项")
        } else {
            if(params.split(",").contains(value)){
                ValidateResult(true)
            }else{
                ValidateResult(false, "必须是选项(${params})")
            }
        }
    }
}